Using a W3D File
This time there is no Havok Export (HKE) file that can be imported. Hence physical information must be supplied through Lingo or taken directly from the 3D world.
First we import the 3D world:
- Click the File menu.
- Select Import from the File menu.
- Select required Shockwave 3D (W3D) file from the dialog window.
This adds the 3D cast member to the cast. This may then be dragged onto the stage. To create the empty Havok simulation:
- Click the Insert menu.
- Select Media Element from the Insert menu.
- Select Havok Physics Scene from the Media Element submenu.
This adds an empty Havok cast member to the cast. Now add a Physics (No HKE) behavior to the cast (from the Havok > Setup behavior library). Playing the movie at this stage will show a static world i.e. we have not associated any rigid bodies with the 3D models in the W3D file.
Now we need to create the Havok simulation information by editing the Physics (No HKE) behavior. The Lingo function below creates two rigid bodies that are added into the Havok simulation and associated with two 3D models from the W3D file, "Box01" and "Text01". The first is a fixed convex rigid body i.e. one that may never move during the simulation. The second is a concave movable object. The full details on these functions are available in the Havok Xtra Lingo Reference manual.
on createScene
s = member( "HelloWorld" )
hk = member( "BlankHavok" )
-- create ground
m = s.model("Box01")
m.addModifier(#meshdeform)
hk.makeFixedRigidBody(m.name)
-- create text
m = s.model("Text01")
m.addModifier(#meshdeform)
hk.makeMovableRigidBody(m.name, 100.0, false)end
In addition to creating the rigid bodies we can alter their default physical parameters at this point. Running the movie should result in some physical animation (i.e. the "Text01" object will fall under gravity).